package com.example.musicdemo1.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.example.musicdemo1.ui.player.PlayerFragment
import com.example.musicdemo1.ui.playlist.PlaylistFragment
import com.example.musicdemo1.ui.recommend.RecommendFragment

class MainPagerAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {
    override fun getItemCount(): Int = 3

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            0 -> RecommendFragment()
            1 -> PlayerFragment()
            2 -> PlaylistFragment()
            else -> throw IllegalArgumentException("Invalid position $position")
        }
    }
} 